﻿using Delphi.Mimir.Config;
using Delphi.Mimir.Data.Entities.Final;
using System.Collections.Generic;
using System.Linq;

namespace Delphi.Mimir.Wrapper {
    public class ParameterWrapper { 

        public static ICollection<Parameter> GetParameters(string domain, string group, string name, string inParm1, string inParm2, string inParm3) {
            ICollection<Parameter> parms = new List<Parameter>();
            using (var context = new DelphiContext()) {
                parms = context.Parameters.Where(a => a.Domain == domain && a.Group == group && a.Name == name 
                    && a.InParm1 == inParm1 && a.InParm2 == inParm2 && a.InParm3 == inParm3).ToList();
            }
            return parms;
        }

        public static ICollection<Parameter> GetParameters(string domain, string group, string name, string inParm1, string inParm2) {
            return GetParameters(domain, group, name, inParm1, inParm2, "");
        }

        public static ICollection<Parameter> GetParameters(string domain, string group, string name, string inParm1) {
            return GetParameters(domain, group, name, inParm1, "", "");
        }

        public static ICollection<Parameter> GetParameters(string domain, string group, string name) {
            return GetParameters(domain, group, name, "", "", "");
        }

        public static Parameter GetParameter(string domain, string group, string name, string inParm1, string inParm2, string inParm3) {
            Parameter parm = new Parameter();
            using (var context = new DelphiContext()) {
                parm = context.Parameters.FirstOrDefault(a => a.Domain == domain && a.Group == group && a.Name == name
                    && a.InParm1 == inParm1 && a.InParm2 == inParm2 && a.InParm3 == inParm3);
            }
            return parm;
        }

        public static Parameter GetParameter(string domain, string group, string name, string inParm1, string inParm2) {
            return GetParameter(domain, group, name, inParm1, inParm2, "");
        }

        public static Parameter GetParameter(string domain, string group, string name, string inParm1) {
            return GetParameter(domain, group, name, inParm1, "", "");
        }

        public static Parameter GetParameter(string domain, string group, string name) {
            return GetParameter(domain, group, name, "", "", "");
        }
    }
}
